package com.example.design.ticket.director;

import com.example.design.ticket.builder.CompanyTicketBuilder;
import com.example.design.ticket.builder.PersonalTicketBuilder;
import org.springframework.stereotype.Component;

//建造者模式具体建造者，代理模式具体主题角色（被代理者）
@Component
public class Director extends AbstractDirector{
    @Override
    public Object buildTicket(String type, String product, String content, String title, String bankInfo, String taxId) {
        if ("personal".equals(type)){
            PersonalTicketBuilder personalTicketBuilder = new PersonalTicketBuilder();
            personalTicketBuilder.setCommonInfo(title, product, content);
            return personalTicketBuilder.buildTicket();

        } else if ("company".equals(type)) {
            CompanyTicketBuilder companyTicketBuilder = new CompanyTicketBuilder();
            companyTicketBuilder.setBankInfo(bankInfo);
            companyTicketBuilder.setCommonInfo(title, product, content);
            companyTicketBuilder.setTaxId(taxId);
            return companyTicketBuilder.buildTicket();
        }
        throw new UnsupportedOperationException("不支持该类型");
    }
}
